import java.util.Scanner;

public class C_1117 {
    public static void main(String[] args) {
        int a,b,c,d,e,f,num,t,flag = 0;
        Scanner sc = new Scanner(System.in);
        num = sc.nextInt();
        for (int i = 10000; i < 1000000; i++) {
            if (i<=99999){
                t = i;
                e = t%10;
                t = t/10;
                d = t%10;
                t = t/10;
                c = t%10;
                t = t/10;
                b = t%10;
                t = t/10;
                a = t%10;
                if (a+b+c+d+e==num&&a==e&&b==d){
                    flag = 1;
                    System.out.println(i);
                }
            }else{
                t = i;
                f = t%10;
                t = t/10;
                e = t%10;
                t = t/10;
                d = t%10;
                t = t/10;
                c = t%10;
                t = t/10;
                b = t%10;
                t = t/10;
                a = t%10;
                if (a+b+c+d+e+f==num&&a==f&&b==e&&c==d){
                    flag = 1;
                    System.out.println(i);
                }
            }

        }
        if (flag == 0){
            System.out.println(-1);
        }
    }
}
